Skip to content

Fix F# option date index member selection#4112

Merged
jeremydmiller merged 4 commits intoJasperFx:masterfrom
nkosi23:master
Feb 6, 2026
Merged

Fix F# option date index member selection#4112
jeremydmiller merged 4 commits intoJasperFx:masterfrom
nkosi23:master

Conversation

@nkosi23
Copy link
Contributor

@nkosi23 nkosi23 commented Feb 4, 2026

Motivation

  • Fix a regression where F# option date/time fields were resolved as generic value types and emitted CAST(... as timestamp)/timestamptz in computed index DDL instead of using the mt_immutable_* functions, which caused Postgres errors about non-immutable functions in index expressions.
  • Ensure the computed index test exercises F# option value type registration so the regression is covered.

Description

  • In src/Marten/StoreOptions.MemberFactory.cs added a guard in ValueTypeMemberSource.TryResolve to skip treating FSharpOption<T> as a generic value type when T is DateTime, DateTimeOffset, DateOnly, or TimeOnly, by returning false early so the specialized DateTimeMember/DateTimeOffsetMember logic is used instead.
  • Added a helper method isSpecialFSharpOptionDateType(Type) to centralize the date/time type check.
  • In src/DocumentDbTests/Indexes/computed_indexes.cs updated the test fsharp_date_related_options_indexes_are_created to call _.RegisterFSharpOptionValueTypes() so the F# option value types are registered during test setup.
  • Added unwrap logic for ConstantExpression expressions as the value of F# options is not accessed as easily as the one of C# nullables.

Testing

  • No automated test suite was executed as part of this change (tests were not run).
  • The fsharp_date_related_options_indexes_are_created test was updated to register F# option value types to cover the regression scenario expected to be validated by the test suite.

Resolves: #4113

@jeremydmiller
Copy link
Member

@nkosi23 I'll look at the LINQ failures tomorrow or Friday

@nkosi23
Copy link
Contributor Author

nkosi23 commented Feb 5, 2026

@jeremydmiller Sorry about that Jeremy, i've just looked into it, they should be fixed now but i'm not sure you'll be happy with the approach.

@jeremydmiller
Copy link
Member

There's a helper extension method somewhere in Marten for selectively unwrapping an Expression like that. I'll get caught up w/ you soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants